٥. كود Google Earth Engine لحساب RVSI (Sentinel-2)
✳ ملاحظة: تأكد من أنك رسمت منطقة الاهتمام geometry على الخريطة
في محرر Google Earth Engine قبل تشغيل الكود.
// RVSI (Red-edge Vegetation Stress Index) using Sentinel-2 SR
// Approximation: RVSI ≈ ((B5 + B7) / 2) - B6
// 1) Load Sentinel-2 Surface Reflectance collection
var collection = ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate('2023-01-01', '2023-12-31') // تعديل الفترة الزمنية حسب احتياجك
.filterBounds(geometry) // geometry: منطقة الدراسة
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20));
// 2) Create median composite
var img = collection.median()
.select(['B5', 'B6', 'B7']); // Red-edge bands
// 3) Compute RVSI
var rvsi = img.expression(
'((R714 + R752) / 2.0) - R733', {
'R714': img.select('B5'), // ≈ 705 nm
'R733': img.select('B6'), // ≈ 740 nm
'R752': img.select('B7') // ≈ 783 nm
}
).rename('RVSI');
// 4) Visualization parameters
var rvsiVis = {
min: -0.05,
max: 0.05,
palette: [
'#440154', '#3b528b', '#21918c', '#5ec962', '#fde725'
]
};
// 5) Add layers to the map
Map.centerObject(geometry, 10);
Map.addLayer(rvsi, rvsiVis, 'RVSI (Sentinel-2)');
Map.addLayer(img.select('B4','B3','B2'), {min:0, max:3000}, 'True Color S2');
// 6) Export to Google Drive as GeoTIFF
Export.image.toDrive({
image: rvsi,
description: 'RVSI_Sentinel2',
fileNamePrefix: 'RVSI_S2',
region: geometry,
scale: 10,
maxPixels: 1e13
});
✅ يمكنك تعديل الفترة الزمنية، نسبة السحب، أو طريقة تجميع الصور (median, mean, mosaic)
حسب طبيعة الدراسة الخاصة بك.